// 新风系统快捷设置
//  ZYVSQuickSetupVC.m
//  YiLin
//
//  Created by Zyark on 2018/6/6.
//  Copyright © 2018年 Zyark. All rights reserved.
//

#import "ZYVSQuickSetupVC.h"
#import "ZYImageUtils.h"
#import "ZYVSModeSettingView.h"
#import "ZYVSAutoModeSettingView.h"
#import "ZYProportionView.h"
#import "ZYDateSelectView.h"
#import "ZYMinuteSelectView.h"
#import "ZYWindSpeedSelectView.h"
#import "ZYFilterSettingView.h"
#import "ZYModeTypeModel.h"
#import "ZYQuickSetupViewModel.h"
#import "ZYDevice.h"
#import "ZYSocketMessageUtils.h"
#import "UINavigationController+FDFullscreenPopGesture.h"

@interface ZYVSQuickSetupVC ()<ZYVSModeSettingViewDelegate,ZYVSAutoModeSettingViewDelegate,ZYProportionViewDelegate,ZYDateSelectViewDelegate,ZYMinuteSelectViewDelegate,ZYWindSpeedSelectViewDelegate,ZYProportionViewDelegate,ZYFilterSettingViewDelegate>
/**
 模式快捷背景
 */
@property(nonatomic,strong) UIView *modeView;

/**
 过滤器背景
 */
@property(nonatomic,strong) UIView *filterView;

/**
 模式快捷按钮
 */
@property(nonatomic,strong) UIButton *modeButton;

/**
 过滤器按钮
 */
@property(nonatomic,strong) UIButton *filterButton;


/**
 模式设置
 */
@property(nonatomic,strong) ZYVSModeSettingView *modeSettingView;

/**
 自动模式
 */
@property(nonatomic,strong) ZYVSAutoModeSettingView *autoModeSettingView;


/**
 弹出比例视图
 */
@property(nonatomic,strong) ZYProportionView *proportionView;


/**
 弹出时间选择
 */
@property(nonatomic,strong) ZYDateSelectView *dateSelectView;


/**
 弹出分钟选择
 */
@property(nonatomic,strong) ZYMinuteSelectView *minuteSelectView;

/**
 弹出风速选择
 */
@property(nonatomic,strong) ZYWindSpeedSelectView *windSpeedSelectView;


/**
 初效过滤器
 */
@property(nonatomic,strong) ZYFilterSettingView *commonFilterSettingView;

/**
 PM2.5过滤器
 */
@property(nonatomic,strong) ZYFilterSettingView *pmFilterSettingView;


/**
 获取默认值
 */
@property(nonatomic,strong) ZYQuickSetupViewModel *viewModel;

/**
 混风模式 风速类型
 */
@property(nonatomic,assign) ZYWindSpeedType windSpeedType;

/**
 混风模式 比例
 */
@property(nonatomic,assign) int proportion;

/**
 自动模式 model
 */
@property(nonatomic,strong) ZYModeTypeModel *autoModel;

@end

@implementation ZYVSQuickSetupVC
typedef NS_ENUM(NSInteger,ZYVSQuickSetupButtonType){
    /**模式快捷*/
    ZYVSQuickSetupButtonTypeMode = 0,
    /**过滤器*/
    ZYVSQuickSetupButtonTypeFilter,
};

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setup];
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.title = [[ZYChangeLanguage sharedZYChangeLanguage] getStringByKey:LC_HOME_EDIT_DEVICE_QUICK_SETUP];
    self.fd_interactivePopDisabled = YES;
    [self.viewModel.vsFilterCommand execute:[NSNumber numberWithUnsignedInteger:_device.serverDeviceType]];//获取默认值
//    [self.viewModel.modeValueCommand execute:[NSNumber numberWithUnsignedInteger:_device.serverDeviceType]];//获取模式值
}

-(void)viewWillDisappear:(BOOL)animated{
    self.fd_interactivePopDisabled = NO;
}

-(void)setup{
    [self setupAutoModel];
    [self setupView];
    [self switchMode:_modeButton];
    [self bindView];
    [self bindViewData];
    
}

-(void)setupView{
    _modeButton = [self setupButton];
    _filterButton = [self setupButton];
    _modeButton.left = 15;
    _modeButton.top = self.navigationView.bottom + 2;
    
    _filterButton.centerY = _modeButton.centerY;
    _filterButton.left = _modeButton.right;
    
    _modeButton.tag = ZYVSQuickSetupButtonTypeMode;
    _filterButton.tag = ZYVSQuickSetupButtonTypeFilter;
    
    _modeView = [[UIView alloc] init];
    _modeView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:_modeView];
    _modeView.size = CGSizeMake(ZYSCREEN_W, ZYSCREEN_H - _modeButton.bottom);
    _modeView.top = _modeButton.bottom + 20;
    _modeView.left = 0;
    
    _filterView = [[UIView alloc] initWithFrame:_modeView.frame];
    [self.view addSubview:_filterView];
    _filterView.hidden = YES;
    
    [self setupModeSettingView];
    [self setupFilterSettingView];
}

-(void)setupModeSettingView{
    _modeSettingView = [[ZYVSModeSettingView alloc] initWithFrame:CGRectMake(0, 0, _modeView.width, _modeView.height *  0.6)];
    _modeSettingView.delegate = self;
    [_modeView addSubview:_modeSettingView];
    
    _autoModeSettingView = [[ZYVSAutoModeSettingView alloc] initWithFrame:CGRectMake(0, 0, _modeView.width, _modeView.height - _modeSettingView.height)];
    [_modeView addSubview:_autoModeSettingView];
    _autoModeSettingView.top = _modeSettingView.bottom;
    _autoModeSettingView.model = _autoModel;
    _autoModeSettingView.delegate = self;
}

-(void)setupFilterSettingView{
    NSArray<NSNumber *> *modeTypeArray = @[[NSNumber numberWithUnsignedInteger:ZYFilterTypeCommon],
                                           [NSNumber numberWithUnsignedInteger:ZYFilterTypeEfficient]];
    NSArray<NSString *> *titleArray = @[LC_QUICK_SETUP_LABEL_FILTER_COMMON,
                                        LC_QUICK_SETUP_LABEL_FILTER_PM];
    NSArray<NSString *> *imageNameArray = @[@"ic_filter_common_unselected",
                                            @"ic_filter_type_pm_unselected"];
    NSMutableArray *array = [NSMutableArray array];
    for (NSUInteger i=0; i<2; i++) {
        ZYModeTypeModel *model = [[ZYModeTypeModel alloc] init];
        model.modeType = [[modeTypeArray objectAtIndex:i] unsignedIntegerValue];
        model.title = [titleArray objectAtIndex:i];
        model.imageName = [imageNameArray objectAtIndex:i];
        [array addObject:model];
    }
    ZYModeTypeModel *commonModel = [array objectAtIndex:0];
    ZYModeTypeModel *pmModel = [array objectAtIndex:1];
    _commonFilterSettingView = [[ZYFilterSettingView alloc] initWithFrame:CGRectMake(0, 0, ZYSCREEN_W, 0)];
    _commonFilterSettingView.model = commonModel;
    _commonFilterSettingView.currentValue = 0;
    _commonFilterSettingView.alreadyUsed = 34;
    _commonFilterSettingView.delegate = self;
    [_filterView addSubview:_commonFilterSettingView];
    _pmFilterSettingView = [[ZYFilterSettingView alloc] initWithFrame:_commonFilterSettingView.bounds];
    _pmFilterSettingView.model = pmModel;
    _pmFilterSettingView.currentValue = 0;
    _pmFilterSettingView.alreadyUsed = 34;
    [_filterView addSubview:_pmFilterSettingView];
    _pmFilterSettingView.top = _commonFilterSettingView.bottom;
    _pmFilterSettingView.delegate = self;
}

-(UIButton *)setupButton{
    UIButton *button = [[UIButton alloc] init];
    button.size =CGSizeMake((ZYSCREEN_W - 30 )/2, ZYSCREEN_W * 0.09);
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
    [button setTitleColor:kLabelColor forState:UIControlStateNormal];
    [button setBackgroundImage:[ZYImageUtils imageWithColor:kMainColor rect:button.bounds] forState:UIControlStateSelected];
    [button setBackgroundImage:[ZYImageUtils imageWithColor:[UIColor whiteColor] rect:button.bounds] forState:UIControlStateNormal];
    button.layer.cornerRadius = 10;
    button.layer.masksToBounds = YES;
    [button addTarget:self action:@selector(switchMode:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    return button;
}

-(void)setupAutoModel{
    _autoModel = [[ZYModeTypeModel alloc] init];
    _autoModel.autoMinute = 30;
    _autoModel.speedType = ZYWindSpeedTypeMiddle;
    _autoModel.startHour = @"07";
    _autoModel.startMinute = @"40";
    _autoModel.endHour = @"10";
    _autoModel.endMinute = @"40";
}

-(void)changeLanguage{
    ZYChangeLanguage *language = [ZYChangeLanguage sharedZYChangeLanguage];
    [_filterButton setTitle:[language getStringByKey:LC_QUICK_SETUP_SETTING_FILTER_BTN_TITLE] forState:UIControlStateNormal];
    [_filterButton setTitle:[language getStringByKey:LC_QUICK_SETUP_SETTING_FILTER_BTN_TITLE] forState:UIControlStateSelected];
    
    [_modeButton setTitle:[language getStringByKey:LC_QUICK_SETUP_SETTING_MODE_BTN_TITLE] forState:UIControlStateNormal];
    [_modeButton setTitle:[language getStringByKey:LC_QUICK_SETUP_SETTING_MODE_BTN_TITLE] forState:UIControlStateSelected];
}

-(void)bindView{
    //过滤器默认值
    @weakify(self)
    [[[self.viewModel.vsFilterCommand executionSignals] switchToLatest] subscribeNext:^(id x) {
        @strongify(self);
        self.commonFilterSettingView.systemValue = [[x objectForKey:[NSString stringWithFormat:@"filtter_%ld",ZYFilterTypeCommon]] floatValue];
        self.pmFilterSettingView.systemValue = [[x objectForKey:[NSString stringWithFormat:@"filtter_%ld",ZYFilterTypeEfficient]] floatValue];
        if(self.commonFilterSettingView.currentValue == 0){
            self.commonFilterSettingView.currentValue = self.commonFilterSettingView.systemValue;
        }
        if(self.pmFilterSettingView.currentValue == 0){
            self.pmFilterSettingView.currentValue = self.pmFilterSettingView.systemValue;
        }
        NSArray *modelArray = [x objectForKey:@"mode"];
        [self setupWithModelArray:modelArray];//初始化默
        [self.viewModel.modeValueCommand execute:[NSNumber numberWithUnsignedInteger:self.device.serverDeviceType]];//获取模式值
    }];
    [self.viewModel.vsFilterCommand.errors subscribeNext:^(id x) {
        @strongify(self);
        if([[NSErrorHelper handleErrorMessage:x] isEqualToString:LOGIN_FAILURE]){
            //登录失效
            [ZYBasicHelper handleErrorMessaeWithError:x message:nil controller:self];
        }
    }];
    
    //获取模式值
    [[[self.viewModel.modeValueCommand executionSignals] switchToLatest] subscribeNext:^(id x) {
        @strongify(self);
        [self setupWithModelArray:x];
    }];
    [self.viewModel.modeValueCommand.errors subscribeNext:^(id x) {
        @strongify(self);
        [ZYBasicHelper handleErrorMessaeWithError:x message:[NSErrorHelper handleErrorMessage:x] controller:self];
    }];
}

-(void)setupWithModelArray:(NSArray *)x{
    NSMutableArray *modelArray = [NSMutableArray array];
    for (ZYModeTypeModel *model in x) {
        if(model.modeType == ZYVSModeTypeAuto){
            self.minuteSelectView.minute = [[NSNumber numberWithUnsignedInteger:model.autoMinute] intValue];
            self.windSpeedSelectView.speedType = model.autoWindSpeedType;
            self.dateSelectView.model = model;
            self.autoModel = model;
            self.autoModeSettingView.model = model;
        }else if(model.modeType == ZYFilterTypeCommon){
            self.commonFilterSettingView.currentValue = model.filterValue;
        }else if(model.modeType == ZYFilterTypeEfficient){
            self.pmFilterSettingView.currentValue = model.filterValue;
        }else{
            [modelArray addObject:model];
            if(model.modeType == ZYVSModeTypeMixedWind){
                self.windSpeedType = model.speedType;
                self.proportion = model.proportion;
                self.proportionView.proportion = model.proportion;
            }
        }
    }
    [self.modeSettingView setValue:modelArray];
}

-(void)bindViewData{
    self.minuteSelectView.minute = [[NSNumber numberWithUnsignedInteger:_autoModel.autoMinute] intValue];
    self.windSpeedSelectView.speedType = _autoModel.autoWindSpeedType;
    self.dateSelectView.model = _autoModel;
    self.proportionView.proportion = _proportion;
}

#pragma mark event
-(void)switchMode:(UIButton *)button{
    [UIView animateWithDuration:0.3 animations:^{
        BOOL isMode = button.tag == ZYVSQuickSetupButtonTypeMode;
        _modeButton.selected = isMode;
        _filterButton.selected = !isMode;
        _modeView.hidden = !isMode;
        _filterView.hidden = isMode;
    }];
}

#pragma mark - ZYVSModeSettingViewDelegate
//风速改变 修改风速
-(void)vsModeSettingView:(ZYVSModeSettingView *)vsModeSettingView changeWindSpeedType:(ZYWindSpeedType)speedType modeType:(ZYVSModeType)modeType{
    _windSpeedType = speedType;
    self.viewModel.mac = _device.mac;
    NSString *params = @"";
    NSDictionary *dict;
    NSUInteger type = speedType;
    if(_device.isNewVS){
        ZYWindSpeedIn100Type windSpeedIn100Type;
        switch (speedType) {
            case ZYWindSpeedTypeHeight:
                windSpeedIn100Type = ZYWindSpeedIn100TypeHeight;
                break;
            case ZYWindSpeedTypeMiddle:
                windSpeedIn100Type = ZYWindSpeedIn100TypeMiddle;
                break;
            case ZYWindSpeedTypeLow:
                windSpeedIn100Type = ZYWindSpeedIn100TypeLow;
                break;
            default:
                windSpeedIn100Type = ZYWindSpeedIn100TypeMiddle;
                break;
        }
        type = windSpeedIn100Type;
    }
    if(modeType == ZYVSModeTypeMixedWind){
        params = [NSString stringWithFormat:@"%ld/%d",speedType,_proportion];
        if(_device.isNewVS){
            dict = @{@"windPannelModel":[NSNumber numberWithUnsignedInteger:modeType],@"windSpeedIn100":[NSNumber numberWithFloat:type],@"valvaAngleInMixWind":[NSNumber numberWithInt:_proportion]};
        }else{
            dict = @{@"windPannelModel":[NSNumber numberWithUnsignedInteger:modeType],@"windSpeed":[NSNumber numberWithFloat:type],@"valvaAngleInMixWind":[NSNumber numberWithInt:_proportion]};
        }
    }else{
        params = [NSString stringWithFormat:@"%ld",speedType];
        if(_device.isNewVS){
            dict = @{@"windPannelModel":[NSNumber numberWithUnsignedInteger:modeType],@"windSpeedIn100":[NSNumber numberWithFloat:type]};
        }else{
            dict = @{@"windPannelModel":[NSNumber numberWithUnsignedInteger:modeType],@"windSpeed":[NSNumber numberWithFloat:type]};
        }
    }
    [self.viewModel setModeValueWithDeviceType:_device.serverDeviceType andModel:modeType andParams:params];
    //socket 控制设备
//    [ZYSocketMessageUtils setDeviceWithMac:_device.mac andParams:dict];
}

//比例按钮点击
-(void)vsModeSettingView:(ZYVSModeSettingView *)vsModeSettingView doProportionClick:(UIButton *)button{
    [self.proportionView showOrHidden];
}

#pragma mark - ZYVSAutoModeSettingViewDelegate
-(void)vsAutoModeSettingView:(ZYVSAutoModeSettingView *)vsAutoModeSettingView doPurificationClick:(UIButton *)button{
    //弹出分钟选择
    [self.minuteSelectView showOrHidden];
}

-(void)vsAutoModeSettingView:(ZYVSAutoModeSettingView *)vsAutoModeSettingView doSleepingClick:(UIButton *)button{
    //弹出时间选择
    [self.dateSelectView showOrHidden];
}

//风速选择
-(void)vsAutoModeSettingView:(ZYVSAutoModeSettingView *)vsAutoModeSettingView doCommonClick:(UIButton *)button{
    [self.windSpeedSelectView showOrHidden];
}

#pragma mark - ZYDateSelectViewDelegate
- (void)dateSelectView:(ZYDateSelectView *)dateSelectView didSelectWithModel:(ZYModeTypeModel *)model{
    _autoModeSettingView.model = model;
    [self modifyAutoModelValue];
}

#pragma mark - ZYMinuteSelectViewDelegate
-(void)minuteSelectView:(ZYMinuteSelectView *)minuteSelectView didSelectWithMinute:(int)minute{
    _autoModel.autoMinute = minute;
    _autoModeSettingView.purificationTime = minute;
    [self modifyAutoModelValue];
}

#pragma mark - ZYWindSpeedSelectViewDelegate
-(void)windSpeedSelectView:(ZYWindSpeedSelectView *)windSpeedSelectView didSelectWithWindSpeedType:(NSUInteger)windSpeedType{
    _autoModel.autoWindSpeedType = windSpeedType;
    _autoModeSettingView.speedType = windSpeedType;
    [self modifyAutoModelValue];
}

#pragma mark - ZYProportionViewDelegate
//比例确认 修改比例
-(void)proportionView:(ZYProportionView *)proportionView doConfirm:(CGFloat)value{
    _proportion = value * 100;
    self.viewModel.mac = _device.mac;
    NSString *params = [NSString stringWithFormat:@"%ld/%d",_windSpeedType,_proportion];
    [self.viewModel setModeValueWithDeviceType:_device.serverDeviceType andModel:ZYVSModeTypeMixedWind andParams:params];
    //socket
    NSUInteger type = _windSpeedType;
    if(_device.isNewVS){
        ZYWindSpeedIn100Type windSpeedIn100Type;
        switch (_windSpeedType) {
            case ZYWindSpeedTypeHeight:
                windSpeedIn100Type = ZYWindSpeedIn100TypeHeight;
                break;
            case ZYWindSpeedTypeMiddle:
                windSpeedIn100Type = ZYWindSpeedIn100TypeMiddle;
                break;
            case ZYWindSpeedTypeLow:
                windSpeedIn100Type = ZYWindSpeedIn100TypeLow;
                break;
            default:
                windSpeedIn100Type = ZYWindSpeedIn100TypeMiddle;
                break;
        }
        type = windSpeedIn100Type;
    }
    NSDictionary *dict;
    if(_device.isNewVS){
        dict = @{@"windPannelModel":[NSNumber numberWithUnsignedInteger:ZYVSModeTypeMixedWind],@"windSpeedIn100":[NSNumber numberWithFloat:type],@"valvaAngleInMixWind":[NSNumber numberWithInt:_proportion]};
    }else{
        dict = @{@"windPannelModel":[NSNumber numberWithUnsignedInteger:ZYVSModeTypeMixedWind],@"windSpeed":[NSNumber numberWithFloat:_windSpeedType],@"valvaAngleInMixWind":[NSNumber numberWithInt:_proportion]};
    }
    //socket 控制设备
//    [ZYSocketMessageUtils setDeviceWithMac:_device.mac andParams:dict];
}

#pragma mark -event
-(void)modifyAutoModelValue{
    self.viewModel.mac = _device.mac;
    //http 设置自动模式
    NSString *params = [NSString stringWithFormat:@"%ld/%ld/%@:%@-%@:%@",_autoModel.autoWindSpeedType,_autoModel.autoMinute,_autoModel.startHour,_autoModel.startMinute,_autoModel.endHour,_autoModel.endMinute];
    [self.viewModel setModeValueWithDeviceType:_device.serverDeviceType andModel:ZYVSModeTypeAuto andParams:params];
    //socket
    NSString *sleepTime = [NSString stringWithFormat:@"%@:%@/%@:%@",_autoModel.startHour,_autoModel.startMinute,_autoModel.endHour,_autoModel.endMinute];
    NSUInteger type = _autoModel.autoWindSpeedType;
    if(_device.isNewVS){
        ZYWindSpeedIn100Type windSpeedIn100Type;
        switch (_autoModel.autoWindSpeedType) {
            case ZYWindSpeedTypeHeight:
                windSpeedIn100Type = ZYWindSpeedIn100TypeHeight;
                break;
            case ZYWindSpeedTypeMiddle:
                windSpeedIn100Type = ZYWindSpeedIn100TypeMiddle;
                break;
            case ZYWindSpeedTypeLow:
                windSpeedIn100Type = ZYWindSpeedIn100TypeLow;
                break;
            default:
                windSpeedIn100Type = ZYWindSpeedIn100TypeMiddle;
                break;
        }
        type = windSpeedIn100Type;
    }
    NSDictionary *dict;
    if(_device.isNewVS){
        dict = @{@"windPannelModel":[NSNumber numberWithUnsignedInteger:ZYVSModeTypeAuto],@"sleepTime":sleepTime,@"cleanTime":[NSNumber numberWithInteger:_autoModel.autoMinute],@"windSpeedIn100":[NSNumber numberWithUnsignedInteger:type]};
    }else{
        dict = @{@"windPannelModel":[NSNumber numberWithUnsignedInteger:ZYVSModeTypeAuto],@"sleepTime":sleepTime,@"cleanTime":[NSNumber numberWithInteger:_autoModel.autoMinute],@"windSpeed":[NSNumber numberWithUnsignedInteger:_autoModel.autoWindSpeedType]};
    }
    //socket 控制设备
//    [ZYSocketMessageUtils setDeviceWithMac:_device.mac andParams:dict];
}

#pragma mark - ZYFilterSettingViewDelegate
-(void)filterSettingView:(ZYFilterSettingView *)filterSettingView changeValue:(CGFloat)value type:(NSUInteger)type{
    NSDictionary *dict;
    if(type == ZYFilterTypeCommon){
        dict = @{@"primaryFilter":[NSString stringWithFormat:@"%.0f",value]};
    }else{
        dict = @{@"advancedFilter":[NSString stringWithFormat:@"%.0f",value]};
    }
    [ZYSocketMessageUtils setDeviceWithMac:_device.mac andParams:dict];
    NSString *params = [NSString stringWithFormat:@"%.0f",value];
    [self.viewModel setModeValueWithDeviceType:_device.serverDeviceType andModel:type andParams:params];
}

-(void)filterSettingView:(ZYFilterSettingView *)filterSettingView doClearClick:(UIButton *)button type:(NSUInteger)type{
    NSDictionary *dict;
    if(type == ZYFilterTypeCommon){
        dict = @{@"primaryFilter":[NSString stringWithFormat:@"%.0f",filterSettingView.currentValue]};
    }else{
        dict = @{@"advancedFilter":[NSString stringWithFormat:@"%.0f",filterSettingView.currentValue]};
    }
    [ZYSocketMessageUtils setDeviceWithMac:_device.mac andParams:dict];
}

#pragma mark - Getter
-(ZYDateSelectView *)dateSelectView{
    if(!_dateSelectView){
        _dateSelectView = [[ZYDateSelectView alloc] initWithFrame:self.view.bounds];
        _dateSelectView.delegate = self;
        [self.view addSubview:_dateSelectView];
    }
    return _dateSelectView;
}

-(ZYMinuteSelectView *)minuteSelectView{
    if(!_minuteSelectView){
        _minuteSelectView = [[ZYMinuteSelectView alloc] initWithFrame:self.view.bounds];
        _minuteSelectView.delegate = self;
        [self.view addSubview:_minuteSelectView];
        
    }
    return _minuteSelectView;
}

-(ZYWindSpeedSelectView *)windSpeedSelectView{
    if(!_windSpeedSelectView){
        _windSpeedSelectView = [[ZYWindSpeedSelectView alloc] initWithFrame:self.view.bounds];
        _windSpeedSelectView.delegate = self;
        [self.view addSubview:_windSpeedSelectView];
    }
    return _windSpeedSelectView;
}

-(ZYProportionView *)proportionView{
    if(!_proportionView){
        _proportionView = [[ZYProportionView alloc] initWithFrame:self.view.bounds];
        _proportionView.delegate = self;
        [self.view addSubview:_proportionView];
    }
    return _proportionView;
}

-(ZYQuickSetupViewModel *)viewModel{
    if(!_viewModel){
        _viewModel = [[ZYQuickSetupViewModel alloc] init];
        _viewModel.mac = _device.mac;
    }
    return _viewModel;
}

@end
